﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;

namespace Web.Common
{
    public class ErpHelper
    {
        public static int InsertOrderIndex(OrderIndexParam m ,string connectionString)
        {
            SqlParameter[] parameters = {
                 new SqlParameter("@BtypeId",SqlDbType.VarChar,50),
                 new SqlParameter("@EtypeId",SqlDbType.VarChar,50),
                 new SqlParameter("@KtypeId",SqlDbType.VarChar,50),
                 new SqlParameter("@BillDate",SqlDbType.DateTime),
                 new SqlParameter("@BillCode",SqlDbType.VarChar,200),
                 new SqlParameter("@BillType",SqlDbType.Int),
                 new SqlParameter("@TotalMoney",SqlDbType.Decimal),
                 new SqlParameter("@TotalQty",SqlDbType.Decimal),
                 new SqlParameter("@Period",SqlDbType.Int),
                 new SqlParameter("@Checked",SqlDbType.Bit),
                 new SqlParameter("@RedWord",SqlDbType.Bit),
                 new SqlParameter("@Explain",SqlDbType.VarChar,250),
                 new SqlParameter("@ReachDate",SqlDbType.DateTime),
                 new SqlParameter("@Comment",SqlDbType.VarChar,250),
                 new SqlParameter("@Checke",SqlDbType.VarChar,50),
                 new SqlParameter("@Tax",SqlDbType.Decimal),
                 new SqlParameter("@BillStatus",SqlDbType.Int),
                 new SqlParameter("@etypeid2",SqlDbType.VarChar,50),
                 new SqlParameter("@WayMode",SqlDbType.VarChar,50),
                 new SqlParameter("@WayBillCode",SqlDbType.VarChar,50),
                 new SqlParameter("@GoodsNumber",SqlDbType.VarChar,20),
                 new SqlParameter("@PackWay",SqlDbType.VarChar,20),
                 new SqlParameter("@TEL",SqlDbType.VarChar,100),
                 new SqlParameter("@DtypeId",SqlDbType.VarChar,50),
                 new SqlParameter("@STypeID",SqlDbType.VarChar,50),
                 new SqlParameter("@CustomerTotal",SqlDbType.Decimal),
                 new SqlParameter("@NCustomerTotal",SqlDbType.Decimal),
                 new SqlParameter("@NTotalMoney",SqlDbType.Decimal),
                 new SqlParameter("@CId",SqlDbType.Int),
                 new SqlParameter("@Rate",SqlDbType.Decimal),
                 new SqlParameter("@BillProperty",SqlDbType.Int),
                 new SqlParameter("@dealbtypeid",SqlDbType.VarChar,50),
                 new SqlParameter("@isyapi",SqlDbType.Int),
                 new SqlParameter("@yapiorderid",SqlDbType.VarChar,20),
                 new SqlParameter("@Discount",SqlDbType.Decimal),
                 new SqlParameter("@ATypeID",SqlDbType.VarChar,50),
                 new SqlParameter("@TotalInMoney",SqlDbType.Decimal),
                 new SqlParameter("@NTotalInMoney",SqlDbType.Decimal),
                 new SqlParameter("@VipCardID",SqlDbType.Int),
                 new SqlParameter("@ReturnValue",SqlDbType.Int) };
            parameters[0].Value = m.BtypeId;
            parameters[1].Value = m.EtypeId;
            parameters[2].Value = m.KtypeId;
            parameters[3].Value = m.BillDate;
            parameters[4].Value = m.BillCode;
            parameters[5].Value = m.BillType;
            parameters[6].Value = m.TotalMoney;
            parameters[7].Value = m.TotalQty;
            parameters[8].Value = m.Period;
            parameters[9].Value = m.Checked;
            parameters[10].Value = m.RedWord;
            parameters[11].Value = m.Explain;
            parameters[12].Value = m.ReachDate;
            parameters[13].Value = m.Comment;
            parameters[14].Value = m.Checke;
            parameters[15].Value = m.Tax;
            parameters[16].Value = m.BillStatus;
            parameters[17].Value = m.etypeid2;
            parameters[18].Value = m.WayMode;
            parameters[19].Value = m.WayBillCode;
            parameters[20].Value = m.GoodsNumber;
            parameters[21].Value = m.PackWay;
            parameters[22].Value = m.TEL;
            parameters[23].Value = m.DtypeId;
            parameters[24].Value = m.STypeID;
            parameters[25].Value = m.CustomerTotal;
            parameters[26].Value = m.NCustomerTotal;
            parameters[27].Value = m.NTotalMoney;
            parameters[28].Value = m.CId;
            parameters[29].Value = m.Rate;
            parameters[30].Value = m.BillProperty;
            parameters[31].Value = m.dealbtypeid;
            parameters[32].Value = m.isyapi;
            parameters[33].Value = m.yapiorderid;
            parameters[34].Value = m.Discount;
            parameters[35].Value = m.ATypeID;
            parameters[36].Value = m.TotalInMoney;
            parameters[37].Value = m.NTotalInMoney;
            parameters[38].Value = m.VipCardID;
            parameters[39].Direction = ParameterDirection.ReturnValue;
            DataSet ds = new FreeADO.DBUtility.DbHelperSQLP(connectionString).RunProcedure("Gp_InsertOrderIndex", parameters, "aaa", 3000);
            return Convert.ToInt32(parameters[39].Value);
        }
        public static void InsertOrderBill(int intFlag,int billNumberId, int billType, List<OrderBillModel> l, string connectionString)
        {
            SqlParameter[] paras ={
                                           new SqlParameter("@intFlag", SqlDbType.Int),
                                           new SqlParameter("@billNumberId", SqlDbType.Int),
                                           new SqlParameter("@billType", SqlDbType.Int),
                                           new SqlParameter("@tb", Newtonsoft.Json.JsonConvert.DeserializeObject<DataTable>(Newtonsoft.Json.JsonConvert.SerializeObject(l))),
                                           new SqlParameter("@ReturnValue", SqlDbType.Int)
            };
            paras[0].Value = intFlag;
            paras[1].Value = billNumberId;
            paras[2].Value = billType;
            paras[3].SqlDbType = SqlDbType.Structured;
            paras[3].TypeName = "dbo.TbType_Order";
            paras[4].Direction = ParameterDirection.ReturnValue;

            DataSet ds = new FreeADO.DBUtility.DbHelperSQLP(connectionString).RunProcedure("Gp_UpdateOrderBillDT", paras, "aaa", 3000);
        }

        public static int InsertBillIndex(BillIndexParam m, string connectionString)
        {
            SqlParameter[] parameters = {
                        new SqlParameter("@BillDate",SqlDbType.DateTime),
                        new SqlParameter("@BillCode",SqlDbType.VarChar,200),
                        new SqlParameter("@BillType",SqlDbType.Decimal),
                        new SqlParameter("@Comment",SqlDbType.VarChar,4000),
                        new SqlParameter("@AtypeId",SqlDbType.VarChar,50),
                        new SqlParameter("@PtypeId",SqlDbType.VarChar,50),
                        new SqlParameter("@BtypeId",SqlDbType.VarChar,50),
                        new SqlParameter("@EtypeId",SqlDbType.VarChar,50),
                        new SqlParameter("@KtypeId",SqlDbType.VarChar,50),
                        new SqlParameter("@KtypeId2",SqlDbType.VarChar,50) ,
                        new SqlParameter("@IfCheck",SqlDbType.Char),
                        new SqlParameter("@CheckE",SqlDbType.VarChar,50) ,
                        new SqlParameter("@TotalMoney",SqlDbType.Decimal),
                        new SqlParameter("@TotalQty",SqlDbType.Decimal),
                        new SqlParameter("@TotalInMoney",SqlDbType.Decimal),
                        new SqlParameter("@Tax",SqlDbType.Decimal),
                        new SqlParameter("@szPeriod",SqlDbType.SmallInt),
                        new SqlParameter("@Explain",SqlDbType.VarChar,4000) ,
                        new SqlParameter("@Draft",SqlDbType.Bit),
                        new SqlParameter("@RedWord",SqlDbType.Bit),
                        new SqlParameter("@OrderId",SqlDbType.Decimal),
                        new SqlParameter("@WayBillCode",SqlDbType.VarChar,50) ,
                        new SqlParameter("@Goodsnumber",SqlDbType.VarChar,20),
                        new SqlParameter("@PackWay",SqlDbType.VarChar,20),
                        new SqlParameter("@Tel",SqlDbType.VarChar,100),
                        new SqlParameter("@preferencemoney",SqlDbType.Decimal),
                        new SqlParameter("@AlertDay",SqlDbType.Int),
                        new SqlParameter("@Assessor",SqlDbType.VarChar,50),
                        new SqlParameter("@IfAudit",SqlDbType.Char),
                        new SqlParameter("@Audit_explain",SqlDbType.VarChar,256),
                        new SqlParameter("@DtypeId",SqlDbType.VarChar,50),
                        new SqlParameter("@VipCardID",SqlDbType.Int),
                        new SqlParameter("@KTypeID3",SqlDbType.VarChar,50),
                        new SqlParameter("@LinkMan",SqlDbType.VarChar,256),
                        new SqlParameter("@LinkTel",SqlDbType.VarChar,256),
                        new SqlParameter("@LinkAddr",SqlDbType.VarChar,256),
                        new SqlParameter("@wxManID",SqlDbType.VarChar,50),
                        new SqlParameter("@JieJianBillNumberID",SqlDbType.VarChar,200),
                        new SqlParameter("@JieJianID",SqlDbType.VarChar,200),
                        new SqlParameter("@BaoXiuBillNumberID",SqlDbType.VarChar,200),
                        new SqlParameter("@BaoXiuID",SqlDbType.VarChar,200),
                        new SqlParameter("@BuyDate",SqlDbType.VarChar,200),
                        new SqlParameter("@Serial",SqlDbType.VarChar,200),
                        new SqlParameter("@wxTotal",SqlDbType.Decimal),
                        new SqlParameter("@ErrDes",SqlDbType.VarChar,3000),
                        new SqlParameter("@ifHideJieJian",SqlDbType.Int),
                        new SqlParameter("@ifWX",SqlDbType.Int),
                        new SqlParameter("@IfBargainOn",SqlDbType.Int),
                        new SqlParameter("@STypeID",SqlDbType.VarChar,50),
                        new SqlParameter("@FromBillNumberID",SqlDbType.Decimal),
                        new SqlParameter("@CostSale",SqlDbType.Bit),
                        new SqlParameter("@completedate",SqlDbType.DateTime),
                        new SqlParameter("@billstate",SqlDbType.Int),
                        new SqlParameter("@ifmulaccount",SqlDbType.Int),
                        new SqlParameter("@vipczmoney",SqlDbType.Decimal),
                        new SqlParameter("@otherinouttype",SqlDbType.Int),
                        new SqlParameter("@czbeforetimes",SqlDbType.Decimal),
                        new SqlParameter("@PosBillType",SqlDbType.Int),
                        new SqlParameter("@TransportId",SqlDbType.VarChar,10) ,
                        new SqlParameter("@IsFreightMoney",SqlDbType.Int),
                        new SqlParameter("@FreightAddr",SqlDbType.VarChar,300) ,
                        new SqlParameter("@FreightPerson",SqlDbType.VarChar,100) ,
                        new SqlParameter("@FreightTel",SqlDbType.VarChar,100) ,
                        new SqlParameter("@ShareMode",SqlDbType.TinyInt),
                        new SqlParameter("@uf1",SqlDbType.VarChar,200),
                        new SqlParameter("@uf2",SqlDbType.VarChar,200),
                        new SqlParameter("@uf3",SqlDbType.VarChar,200),
                        new SqlParameter("@uf4",SqlDbType.VarChar,200),
                        new SqlParameter("@uf5",SqlDbType.VarChar,200),
                        new SqlParameter("@DEALBTYPEID",SqlDbType.VarChar,50),
                        new SqlParameter("@cid",SqlDbType.Int),
                        new SqlParameter("@rate",SqlDbType.Decimal),
                        new SqlParameter("@ntotalmoney",SqlDbType.Money),
                        new SqlParameter("@ntotalinmoney",SqlDbType.Money),
                        new SqlParameter("@npreferencemoney",SqlDbType.Money),
                        new SqlParameter("@nvipczmoney",SqlDbType.Money),
                        new SqlParameter("@atypeid1",SqlDbType.VarChar,50),
                        new SqlParameter("@billproperty",SqlDbType.Int),
                        new SqlParameter("@ncompletetotal",SqlDbType.Decimal),
                        new SqlParameter("@isini",SqlDbType.Bit),
                        new SqlParameter("@ATID",SqlDbType.Int),
                        new SqlParameter("@completetotal",SqlDbType.Decimal),
                        new SqlParameter("@IfCargo",SqlDbType.Bit),
                        new SqlParameter("@IfInvoice",SqlDbType.Int),
                        new SqlParameter("@invoicemoney",SqlDbType.Decimal),
                        new SqlParameter("@ninvoicemoney",SqlDbType.Decimal),
                        new SqlParameter("@importtype",SqlDbType.TinyInt),
                        new SqlParameter("@AssetBusinessTypeId",SqlDbType.Int),
                        new SqlParameter("@promoruleid",SqlDbType.Int),
                        new SqlParameter("@beforepromobillnumberid",SqlDbType.Int),
                        new SqlParameter("@promotionmsg",SqlDbType.VarChar,500),
                        new SqlParameter("@STypeID2",SqlDbType.VarChar,50),
                        new SqlParameter("@ifconfirm",SqlDbType.Int),
                        new SqlParameter("@FeeDeductType",SqlDbType.Int),
                        new SqlParameter("@TransferType",SqlDbType.Int),
                        new SqlParameter("@isyapi",SqlDbType.Int),
                        new SqlParameter("@yapiorderid",SqlDbType.VarChar,20),
                        new SqlParameter("@DeliveryAddress",SqlDbType.VarChar,256),
                        new SqlParameter("@Discount",SqlDbType.Decimal),
                        new SqlParameter("@AdpriceType",SqlDbType.Int),
                        new SqlParameter("@checkSave",SqlDbType.VarChar,128),
                        new SqlParameter("@chargeoffbtypeid",SqlDbType.VarChar,50),
                        new SqlParameter("@chargeofftype",SqlDbType.Int),
                        new SqlParameter("@chargeofftotal",SqlDbType.Decimal),
                        new SqlParameter("@nchargeofftotal",SqlDbType.Decimal),
                        new SqlParameter("@IsLend",SqlDbType.Int),
                        new SqlParameter("@WarehouseOutDay",SqlDbType.Int),
                        new SqlParameter("@StockInDeadline",SqlDbType.Int),
                        new SqlParameter("@IsNeedTransport",SqlDbType.Bit),
                        new SqlParameter("@iscombinationstyle",SqlDbType.Int),
                        new SqlParameter("@transporterid",SqlDbType.VarChar,50),
                        new SqlParameter("@transporterfullname",SqlDbType.VarChar,200),
                        new SqlParameter("@shipperfullname",SqlDbType.VarChar,100),
                        new SqlParameter("@shipperperson",SqlDbType.VarChar,100),
                        new SqlParameter("@shippertel",SqlDbType.VarChar,100),
                        new SqlParameter("@transportno",SqlDbType.VarChar,200),
                        new SqlParameter("@totalfreight",SqlDbType.Decimal),
                        new SqlParameter("@ntotalfreight",SqlDbType.Decimal),
                        new SqlParameter("@PromonIds",SqlDbType.VarChar,1000),
                        new SqlParameter("@isByBrandarType",SqlDbType.Int),
                        new SqlParameter("@NewPosBill",SqlDbType.Int),
                        new SqlParameter("@PayOnTheSpot",SqlDbType.Int),
                        new SqlParameter("@posid",SqlDbType.Int),
                        new SqlParameter("@allowinvoicing",SqlDbType.Int),
                        new SqlParameter("@ReturnValue",SqlDbType.Int)

            };
            parameters[0].Value = m.BillDate;
            parameters[1].Value = m.BillCode;
            parameters[2].Value = m.BillType;
            parameters[3].Value = m.Comment;
            parameters[4].Value = m.AtypeId;
            parameters[5].Value = m.PtypeId;
            parameters[6].Value = m.BtypeId;
            parameters[7].Value = m.EtypeId;
            parameters[8].Value = m.KtypeId;
            parameters[9].Value = m.KtypeId2;
            parameters[10].Value = m.IfCheck;
            parameters[11].Value = m.CheckE;
            parameters[12].Value = m.TotalMoney;
            parameters[13].Value = m.TotalQty;
            parameters[14].Value = m.TotalInMoney;
            parameters[15].Value = m.Tax;
            parameters[16].Value = m.szPeriod;
            parameters[17].Value = m.Explain;
            parameters[18].Value = m.Draft;
            parameters[19].Value = m.RedWord;
            parameters[20].Value = m.OrderId;
            parameters[21].Value = m.WayBillCode;
            parameters[22].Value = m.Goodsnumber;
            parameters[23].Value = m.PackWay;
            parameters[24].Value = m.Tel;
            parameters[25].Value = m.preferencemoney;
            parameters[26].Value = m.AlertDay;
            parameters[27].Value = m.Assessor;
            parameters[28].Value = m.IfAudit;
            parameters[29].Value = m.Audit_explain;
            parameters[30].Value = m.DtypeId;
            parameters[31].Value = m.VipCardID;
            parameters[32].Value = m.KTypeID3;
            parameters[33].Value = m.LinkMan;
            parameters[34].Value = m.LinkTel;
            parameters[35].Value = m.LinkAddr;
            parameters[36].Value = m.wxManID;
            parameters[37].Value = m.JieJianBillNumberID;
            parameters[38].Value = m.JieJianID;
            parameters[39].Value = m.BaoXiuBillNumberID;
            parameters[40].Value = m.BaoXiuID;
            parameters[41].Value = m.BuyDate;
            parameters[42].Value = m.Serial;
            parameters[43].Value = m.wxTotal;
            parameters[44].Value = m.ErrDes;
            parameters[45].Value = m.ifHideJieJian;
            parameters[46].Value = m.ifWX;
            parameters[47].Value = m.IfBargainOn;
            parameters[48].Value = m.STypeID;
            parameters[49].Value = m.FromBillNumberID;
            parameters[50].Value = m.CostSale;
            parameters[51].Value = m.completedate;
            parameters[52].Value = m.billstate;
            parameters[53].Value = m.ifmulaccount;
            parameters[54].Value = m.vipczmoney;
            parameters[55].Value = m.otherinouttype;
            parameters[56].Value = m.czbeforetimes;
            parameters[57].Value = m.PosBillType;
            parameters[58].Value = m.TransportId;
            parameters[59].Value = m.IsFreightMoney;
            parameters[60].Value = m.FreightAddr;
            parameters[61].Value = m.FreightPerson;
            parameters[62].Value = m.FreightTel;
            parameters[63].Value = m.ShareMode;
            parameters[64].Value = m.uf1;
            parameters[65].Value = m.uf2;
            parameters[66].Value = m.uf3;
            parameters[67].Value = m.uf4;
            parameters[68].Value = m.uf5;
            parameters[69].Value = m.DEALBTYPEID;
            parameters[70].Value = m.cid;
            parameters[71].Value = m.rate;
            parameters[72].Value = m.ntotalmoney;
            parameters[73].Value = m.ntotalinmoney;
            parameters[74].Value = m.npreferencemoney;
            parameters[75].Value = m.nvipczmoney;
            parameters[76].Value = m.atypeid1;
            parameters[77].Value = m.billproperty;
            parameters[78].Value = m.ncompletetotal;
            parameters[79].Value = m.isini;
            parameters[80].Value = m.ATID;
            parameters[81].Value = m.completetotal;
            parameters[82].Value = m.IfCargo;
            parameters[83].Value = m.IfInvoice;
            parameters[84].Value = m.invoicemoney;
            parameters[85].Value = m.ninvoicemoney;
            parameters[86].Value = m.importtype;
            parameters[87].Value = m.AssetBusinessTypeId;
            parameters[88].Value = m.promoruleid;
            parameters[89].Value = m.beforepromobillnumberid;
            parameters[90].Value = m.promotionmsg;
            parameters[91].Value = m.STypeID2;
            parameters[92].Value = m.ifconfirm;
            parameters[93].Value = m.FeeDeductType;
            parameters[94].Value = m.TransferType;
            parameters[95].Value = m.isyapi;
            parameters[96].Value = m.yapiorderid;
            parameters[97].Value = m.DeliveryAddress;
            parameters[98].Value = m.Discount;
            parameters[99].Value = m.AdpriceType;
            parameters[100].Value = m.checkSave;
            parameters[101].Value = m.chargeoffbtypeid;
            parameters[102].Value = m.chargeofftype;
            parameters[103].Value = m.chargeofftotal;
            parameters[104].Value = m.nchargeofftotal;
            parameters[105].Value = m.IsLend;
            parameters[106].Value = m.WarehouseOutDay;
            parameters[107].Value = m.StockInDeadline;
            parameters[108].Value = m.IsNeedTransport;
            parameters[109].Value = m.iscombinationstyle;
            parameters[110].Value = m.transporterid;
            parameters[111].Value = m.transporterfullname;
            parameters[112].Value = m.shipperfullname;
            parameters[113].Value = m.shipperperson;
            parameters[114].Value = m.shippertel;
            parameters[115].Value = m.transportno;
            parameters[116].Value = m.totalfreight;
            parameters[117].Value = m.ntotalfreight;
            parameters[118].Value = m.PromonIds;
            parameters[119].Value = m.isByBrandarType;
            parameters[120].Value = m.NewPosBill;
            parameters[121].Value = m.PayOnTheSpot;
            parameters[122].Value = m.posid;
            parameters[123].Value = m.allowinvoicing;
            parameters[124].Direction = ParameterDirection.ReturnValue;
            DataSet ds = new FreeADO.DBUtility.DbHelperSQLP(connectionString).RunProcedure("Gp_InsertBillIndex", parameters, "aaa", 3000);
            return Convert.ToInt32(parameters[124].Value);
        }
        public static void InsertSaleBackBill(List<SaleBackModel> l, string connectionString)
        {
            SqlParameter[] paras ={
                                           new SqlParameter("@details", Newtonsoft.Json.JsonConvert.DeserializeObject<DataTable>(Newtonsoft.Json.JsonConvert.SerializeObject(l))),
                                           new SqlParameter("@ReturnValue", SqlDbType.Int)
            };
            paras[0].SqlDbType = SqlDbType.Structured;
            paras[0].TypeName = "dbo.TBType_SaleBack";
            paras[1].Direction = ParameterDirection.ReturnValue;

            DataSet ds = new FreeADO.DBUtility.DbHelperSQLP(connectionString).RunProcedure("Gp_InsertSaleBackBillDT", paras, "aaa", 3000);
        }
    }


    public class OrderIndexParam
    {
        public string BtypeId { get; set; }
        public string EtypeId { get; set; }
        public string KtypeId { get; set; }
        public DateTime? BillDate { get; set; }
        public string BillCode { get; set; }
        public int BillType { get; set; }
        public decimal TotalMoney { get; set; }
        public decimal TotalQty { get; set; }
        public int Period { get; set; }
        public bool Checked { get; set; }
        public bool RedWord { get; set; }
        public string Explain { get; set; }
        public DateTime? ReachDate { get; set; }
        public string Comment { get; set; }
        public string Checke { get; set; }
        public decimal Tax { get; set; }
        public int BillStatus { get; set; }
        public string etypeid2 { get; set; }
        public string WayMode { get; set; }
        public string WayBillCode { get; set; }
        public string GoodsNumber { get; set; }
        public string PackWay { get; set; }
        public string TEL { get; set; }
        public string DtypeId { get; set; }
        public string STypeID { get; set; }
        public decimal CustomerTotal { get; set; }
        public decimal NCustomerTotal { get; set; }
        public decimal NTotalMoney { get; set; }
        public int CId { get; set; }
        public decimal Rate { get; set; }
        public int BillProperty { get; set; }
        public string dealbtypeid { get; set; }
        public int isyapi { get; set; }
        public string yapiorderid { get; set; }
        public decimal Discount { get; set; }
        public string ATypeID { get; set; }
        public decimal TotalInMoney { get; set; }
        public decimal NTotalInMoney { get; set; }
        public int VipCardID { get; set; }
        public OrderIndexParam()
        {
            BtypeId = "";
            EtypeId = "00001";
            KtypeId = "";
            BillDate = null;
            BillCode = "";
            BillType = 0;
            TotalMoney = 0;
            TotalQty = 0;
            Period = 1;
            Checked = false;
            RedWord = false;
            Explain = "";
            ReachDate = null;
            Comment = "";
            Checke = "";
            Tax = 0;
            BillStatus = 0;
            etypeid2 = "";
            WayMode = "";
            WayBillCode = "";
            GoodsNumber = "";
            PackWay = "";
            TEL = "";
            DtypeId = "";
            STypeID = "00001";
            CustomerTotal = 0;
            NCustomerTotal = 0;
            NTotalMoney = 0;
            CId = 0;
            Rate = 0;
            BillProperty = 0;
            dealbtypeid = "";
            isyapi = 0;
            yapiorderid = "";
            Discount = 1;
            ATypeID = "";
            TotalInMoney = 0;
            NTotalInMoney = 0;
            VipCardID = -1;
        }
    }
    public class OrderBillModel
    {
        public string chvPTypeID { get; set; }
        public decimal numQty { get; set; }
        public decimal numPrice { get; set; }
        public decimal numTotal { get; set; }
        public string chvComment { get; set; }
        public int intOrderID { get; set; }
        public int intIsUnitTow { get; set; }
        public decimal numReachQty { get; set; }
        public decimal numDiscount { get; set; }
        public decimal numDiscountPrice { get; set; }
        public decimal numTaxPrice { get; set; }
        public decimal numTaxTotal { get; set; }
        public decimal numSaleTotal { get; set; }
        public decimal numTax { get; set; }
        public string KTypeID { get; set; }
        public string STypeID { get; set; }
        public int FromBillNumberID { get; set; }
        public int FromBillID { get; set; }
        public int requestbillnumberid { get; set; }
        public int requestbillid { get; set; }
        public int askbillnumberid { get; set; }
        public int askbillid { get; set; }
        public decimal TaxMoney { get; set; }
        public decimal NSalePrice { get; set; }
        public decimal NSaleTotal { get; set; }
        public decimal NDiscountPrice { get; set; }
        public decimal NTotal { get; set; }
        public decimal NTaxPrice { get; set; }
        public decimal NTaxTotal { get; set; }
        public decimal NTaxMoney { get; set; }
        public int UnitId { get; set; }
        public int NUnitId { get; set; }
        public decimal NQty { get; set; }
        public decimal UnitRate { get; set; }
        public string NUnitMsg { get; set; }
        public int MUnitId { get; set; }
        public decimal MQty { get; set; }
        public decimal MUnitRate { get; set; }
        public string MUnitMsg { get; set; }
        public decimal MSalePrice { get; set; }
        public decimal MDiscountPrice { get; set; }
        public decimal MTaxPrice { get; set; }
        public decimal CurMSalePrice { get; set; }
        public decimal CurMDiscountPrice { get; set; }
        public decimal CurMTaxPrice { get; set; }
        public int ItemId { get; set; }
        public int IsCombined { get; set; }
        public string GoodsNumber { get; set; }
        public int CargoID { get; set; }
        public decimal GoodsCostPrice { get; set; }
        public int GoodsOrder { get; set; }
        public string ProduceDate { get; set; }
        public string ValidDate { get; set; }
        public int isrequest { get; set; }
        public decimal oldcurmtaxprice { get; set; }
        public decimal oldqty { get; set; }
        public string entrycode { get; set; }
        public int isgift { get; set; }
        public string YapiID { get; set; }
        public string PriceSource { get; set; }
        public int OrderId { get; set; }
        public int Id { get; set; }
        public int PromoType { get; set; }
        public int ShowOrder { get; set; }
        public decimal SaleOrderReachQty { get; set; }
        public int SaleOrderId { get; set; }
        public int PTCombinOrderBillDetailID { get; set; }
        public OrderBillModel()
        {
            chvPTypeID = "";
            numQty = 0;
            numPrice = 0;
            numTotal = 0;
            chvComment = "";
            intOrderID = 0;
            intIsUnitTow = 0;
            numReachQty = 0;
            numDiscount = 1;
            numDiscountPrice = 0;
            numTaxPrice = 0;
            numTaxTotal = 0;
            numSaleTotal = 0;
            numTax = 0;
            KTypeID = "";
            STypeID = "";
            FromBillNumberID = 0;
            FromBillID = 0;
            requestbillnumberid = 0;
            requestbillid = 0;
            askbillnumberid = 0;
            askbillid = 0;
            TaxMoney = 0;
            NSalePrice = 0;
            NSaleTotal = 0;
            NDiscountPrice = 0;
            NTotal = 0;
            NTaxPrice = 0;
            NTaxTotal = 0;
            NTaxMoney = 0;
            UnitId = 0;
            NUnitId = 0;
            NQty = 0;
            UnitRate = 0;
            NUnitMsg = "";
            MUnitId = 0;
            MQty = 0;
            MUnitRate = 0;
            MUnitMsg = "";
            MSalePrice = 0;
            MDiscountPrice = 0;
            MTaxPrice = 0;
            CurMSalePrice = 0;
            CurMDiscountPrice = 0;
            CurMTaxPrice = 0;
            ItemId = 0;
            IsCombined = 0;
            GoodsNumber = "";
            CargoID = 0;
            GoodsCostPrice = 0;
            GoodsOrder = -1;
            ProduceDate = "";
            ValidDate = "";
            isrequest = 0;
            oldcurmtaxprice = 0;
            oldqty = 0;
            entrycode = "";
            isgift = 0;
            YapiID = "";
            PriceSource = "";
            OrderId = 0;
            Id = 0;
            PromoType = 0;
            ShowOrder = 0;
            SaleOrderReachQty = 0;
            SaleOrderId = 0;
            PTCombinOrderBillDetailID = 0;

        }
    }
    public class BillIndexParam
    {
        public DateTime? BillDate { get; set; }
        public string BillCode { get; set; }
        public decimal BillType { get; set; }
        public string Comment { get; set; }
        public string AtypeId { get; set; }
        public string PtypeId { get; set; }
        public string BtypeId { get; set; }
        public string EtypeId { get; set; }
        public string KtypeId { get; set; }
        public string KtypeId2 { get; set; }
        public string IfCheck { get; set; }
        public string CheckE { get; set; }
        public decimal TotalMoney { get; set; }
        public decimal TotalQty { get; set; }
        public decimal TotalInMoney { get; set; }
        public decimal Tax { get; set; }
        public int szPeriod { get; set; }
        public string Explain { get; set; }
        public bool Draft { get; set; }
        public bool RedWord { get; set; }
        public decimal OrderId { get; set; }
        public string WayBillCode { get; set; }
        public string Goodsnumber { get; set; }
        public string PackWay { get; set; }
        public string Tel { get; set; }
        public decimal preferencemoney { get; set; }
        public int AlertDay { get; set; }
        public string Assessor { get; set; }
        public string IfAudit { get; set; }
        public string Audit_explain { get; set; }
        public string DtypeId { get; set; }
        public int VipCardID { get; set; }
        public string KTypeID3 { get; set; }
        public string LinkMan { get; set; }
        public string LinkTel { get; set; }
        public string LinkAddr { get; set; }
        public string wxManID { get; set; }
        public string JieJianBillNumberID { get; set; }
        public string JieJianID { get; set; }
        public string BaoXiuBillNumberID { get; set; }
        public string BaoXiuID { get; set; }
        public string BuyDate { get; set; }
        public string Serial { get; set; }
        public decimal wxTotal { get; set; }
        public string ErrDes { get; set; }
        public int ifHideJieJian { get; set; }
        public int ifWX { get; set; }
        public int IfBargainOn { get; set; }
        public string STypeID { get; set; }
        public decimal FromBillNumberID { get; set; }
        public bool CostSale { get; set; }
        public DateTime? completedate { get; set; }
        public int billstate { get; set; }
        public int ifmulaccount { get; set; }
        public decimal vipczmoney { get; set; }
        public int otherinouttype { get; set; }
        public decimal czbeforetimes { get; set; }
        public int PosBillType { get; set; }
        public string TransportId { get; set; }
        public int IsFreightMoney { get; set; }
        public string FreightAddr { get; set; }
        public string FreightPerson { get; set; }
        public string FreightTel { get; set; }
        public int ShareMode { get; set; }
        public string uf1 { get; set; }
        public string uf2 { get; set; }
        public string uf3 { get; set; }
        public string uf4 { get; set; }
        public string uf5 { get; set; }
        public string DEALBTYPEID { get; set; }
        public int cid { get; set; }
        public decimal rate { get; set; }
        public decimal ntotalmoney { get; set; }
        public decimal ntotalinmoney { get; set; }
        public decimal npreferencemoney { get; set; }
        public decimal nvipczmoney { get; set; }
        public string atypeid1 { get; set; }
        public int billproperty { get; set; }
        public decimal ncompletetotal { get; set; }
        public bool isini { get; set; }
        public int ATID { get; set; }
        public decimal completetotal { get; set; }
        public bool IfCargo { get; set; }
        public int IfInvoice { get; set; }
        public decimal invoicemoney { get; set; }
        public decimal ninvoicemoney { get; set; }
        public int importtype { get; set; }
        public int AssetBusinessTypeId { get; set; }
        public int promoruleid { get; set; }
        public int beforepromobillnumberid { get; set; }
        public string promotionmsg { get; set; }
        public string STypeID2 { get; set; }
        public int ifconfirm { get; set; }
        public int FeeDeductType { get; set; }
        public int TransferType { get; set; }
        public int isyapi { get; set; }
        public string yapiorderid { get; set; }
        public string DeliveryAddress { get; set; }
        public decimal Discount { get; set; }
        public int AdpriceType { get; set; }
        public string checkSave { get; set; }
        public string chargeoffbtypeid { get; set; }
        public int chargeofftype { get; set; }
        public decimal chargeofftotal { get; set; }
        public decimal nchargeofftotal { get; set; }
        public int IsLend { get; set; }
        public int WarehouseOutDay { get; set; }
        public int StockInDeadline { get; set; }
        public bool IsNeedTransport { get; set; }
        public int iscombinationstyle { get; set; }
        public string transporterid { get; set; }
        public string transporterfullname { get; set; }
        public string shipperfullname { get; set; }
        public string shipperperson { get; set; }
        public string shippertel { get; set; }
        public string transportno { get; set; }
        public decimal totalfreight { get; set; }
        public decimal ntotalfreight { get; set; }
        public string PromonIds { get; set; }
        public int isByBrandarType { get; set; }
        public int NewPosBill { get; set; }
        public int PayOnTheSpot { get; set; }
        public int posid { get; set; }
        public int allowinvoicing { get; set; }

        public BillIndexParam()
        {
            BillDate = null;
            BillCode = "";
            BillType = 0;
            Comment = "";
            AtypeId = "";
            PtypeId = "";
            BtypeId = "";
            EtypeId = "";
            KtypeId = "";
            KtypeId2 = "";
            IfCheck = "";
            CheckE = "";
            TotalMoney = 0;
            TotalQty = 0;
            TotalInMoney = 0;
            Tax = 0;
            szPeriod = 0;
            Explain = "";
            Draft = false;
            RedWord = false;
            OrderId = 0;
            WayBillCode = "";
            Goodsnumber = "";
            PackWay = "";
            Tel = "";
            preferencemoney = 0;
            AlertDay = 9999;
            Assessor = "";
            IfAudit = "3";
            Audit_explain = "";
            DtypeId = "";
            VipCardID = -1;
            KTypeID3 = "";
            LinkMan = "";
            LinkTel = "";
            LinkAddr = "";
            wxManID = "";
            JieJianBillNumberID = "";
            JieJianID = "";
            BaoXiuBillNumberID = "";
            BaoXiuID = "";
            BuyDate = "";
            Serial = "";
            wxTotal = 0;
            ErrDes = "";
            ifHideJieJian = 0;
            ifWX = 0;
            IfBargainOn = 0;
            STypeID = "";
            FromBillNumberID = 0;
            CostSale = false;
            completedate = null;
            billstate = 0;
            ifmulaccount = 0;
            vipczmoney = 0;
            otherinouttype = 0;
            czbeforetimes = 0;
            PosBillType = 0;
            TransportId = "";
            IsFreightMoney = 0;
            FreightAddr = "";
            FreightPerson = "";
            FreightTel = "";
            ShareMode = 0;
            uf1 = "";
            uf2 = "";
            uf3 = "";
            uf4 = "";
            uf5 = "";
            DEALBTYPEID = "";
            cid = 0;
            rate = 0;
            ntotalmoney = 0;
            ntotalinmoney = 0;
            npreferencemoney = 0;
            nvipczmoney = 0;
            atypeid1 = "";
            billproperty = 0;
            ncompletetotal = 0;
            isini = false;
            ATID = 0;
            completetotal = 0;
            IfCargo = false;
            IfInvoice = 0;
            invoicemoney = 0;
            ninvoicemoney = 0;
            importtype = 0;
            AssetBusinessTypeId = 0;
            promoruleid = 0;
            beforepromobillnumberid = 0;
            promotionmsg = "";
            STypeID2 = "";
            ifconfirm = 0;
            FeeDeductType = 0;
            TransferType = 1;
            isyapi = 0;
            yapiorderid = "0";
            DeliveryAddress = "";
            Discount = 1;
            AdpriceType = 0;
            checkSave = "";
            chargeoffbtypeid = "";
            chargeofftype = 0;
            chargeofftotal = 0;
            nchargeofftotal = 0;
            IsLend = 0;
            WarehouseOutDay = 9999;
            StockInDeadline = 9999;
            IsNeedTransport = false;
            iscombinationstyle = 0;
            transporterid = "0";
            transporterfullname = "";
            shipperfullname = "";
            shipperperson = "";
            shippertel = "";
            transportno = "";
            totalfreight = 0;
            ntotalfreight = 0;
            PromonIds = "";
            isByBrandarType = 0;
            NewPosBill = 0;
            PayOnTheSpot = 0;
            posid = 0;
            allowinvoicing = 1;
        }
    }
    public class SaleBackModel
    {

        public int BillNumberId { get; set; }
        public string PtypeId { get; set; }
        public decimal Qty { get; set; }
        public decimal SalePrice { get; set; }
        public decimal Discount { get; set; }
        public decimal DiscountPrice { get; set; }
        public string JobNo { get; set; }
        public decimal Total { get; set; }
        public DateTime? MakeDate { get; set; }
        public decimal TaxPrice { get; set; }
        public decimal TaxTotal { get; set; }
        public string Comment { get; set; }
        public int intisUnit2 { get; set; }
        public string Serial { get; set; }
        public string OldID { get; set; }
        public int OldBillNumberID { get; set; }
        public decimal InputCostPrice { get; set; }
        public string GoodsNumber { get; set; }
        public string ProduceDate { get; set; }
        public string ValidDate { get; set; }
        public string GoodsBTypeID { get; set; }
        public decimal GoodsCostPrice { get; set; }
        public int HandZeroCost { get; set; }
        public decimal Tax { get; set; }
        public decimal SaleTotal { get; set; }
        public string KTypeID { get; set; }
        public string STypeID { get; set; }
        public decimal FromBillNumberID { get; set; }
        public decimal FromBillID { get; set; }
        public decimal TaxMoney { get; set; }
        public decimal NSalePrice { get; set; }
        public decimal NSaleTotal { get; set; }
        public decimal NDiscountPrice { get; set; }
        public decimal NTotal { get; set; }
        public decimal NTaxPrice { get; set; }
        public decimal NTaxTotal { get; set; }
        public decimal NTaxMoney { get; set; }
        public int CargoId { get; set; }
        public int UnitId { get; set; }
        public int NUnitId { get; set; }
        public decimal NQty { get; set; }
        public decimal UnitRate { get; set; }
        public string NUnitMsg { get; set; }
        public int MUnitId { get; set; }
        public decimal MQty { get; set; }
        public decimal MUnitRate { get; set; }
        public string MUnitMsg { get; set; }
        public decimal MSalePrice { get; set; }
        public decimal MDiscountPrice { get; set; }
        public decimal MTaxPrice { get; set; }
        public decimal CurMSalePrice { get; set; }
        public decimal CurMDiscountPrice { get; set; }
        public decimal CurMTaxPrice { get; set; }
        public int ItemId { get; set; }
        public int IsCombined { get; set; }
        public decimal CompleteQTY { get; set; }
        public decimal InvoiceQty { get; set; }
        public decimal InvoiceMoney { get; set; }
        public decimal NInvoiceMoney { get; set; }
        public int IsGift { get; set; }
        public decimal ReferPrice { get; set; }
        public int PriceStyle { get; set; }
        public int PromoType { get; set; }
        public int OMBillID { get; set; }
        public decimal CompleteTotal { get; set; }
        public decimal NCompleteTotal { get; set; }
        public int ID { get; set; }
        public int ShowOrder { get; set; }
        public string ETypeID { get; set; }
        public string PriceSource { get; set; }
        public string CouponCode { get; set; }


        public SaleBackModel()
        {
            BillNumberId = 0;
            PtypeId = "";
            Qty = 0;
            SalePrice = 0;
            Discount = 0;
            DiscountPrice = 0;
            JobNo = "";
            Total = 0;
            MakeDate = null;
            TaxPrice = 0;
            TaxTotal = 0;
            Comment = "";
            intisUnit2 = 0;
            Serial = "";
            OldID = "";
            OldBillNumberID = 0;
            InputCostPrice = 0;
            GoodsNumber = "";
            ProduceDate = "";
            ValidDate = "";
            GoodsBTypeID = "";
            GoodsCostPrice = 0;
            HandZeroCost = 0;
            Tax = 0;
            SaleTotal = 0;
            KTypeID = "";
            STypeID = "";
            FromBillNumberID = 0;
            FromBillID = 0;
            TaxMoney = 0;
            NSalePrice = 0;
            NSaleTotal = 0;
            NDiscountPrice = 0;
            NTotal = 0;
            NTaxPrice = 0;
            NTaxTotal = 0;
            NTaxMoney = 0;
            CargoId = 0;
            UnitId = 0;
            NUnitId = 0;
            NQty = 0;
            UnitRate = 0;
            NUnitMsg = "";
            MUnitId = 0;
            MQty = 0;
            MUnitRate = 0;
            MUnitMsg = "";
            MSalePrice = 0;
            MDiscountPrice = 0;
            MTaxPrice = 0;
            CurMSalePrice = 0;
            CurMDiscountPrice = 0;
            CurMTaxPrice = 0;
            ItemId = 0;
            IsCombined = 0;
            CompleteQTY = 0;
            InvoiceQty = 0;
            InvoiceMoney = 0;
            NInvoiceMoney = 0;
            IsGift = 0;
            ReferPrice = 0;
            PriceStyle = 0;
            PromoType = 0;
            OMBillID = 0;
            CompleteTotal = 0;
            NCompleteTotal = 0;
            ID = 0;
            ShowOrder = 0;
            ETypeID = "";
            PriceSource = "";
            CouponCode = "";

        }
    }
}